/**
 * Stores the coordinate in latitude and longitude format
 *
 * provides the ability to return the coordinate as a point or as seperate coords
 *
 * west and south being negative coordinates
 *
 */


public class Coord {
	private double longitude, latitude;
	
	public boolean leftOf(Coord c) {
		if (longitude < c.getLongitude()) return true;
		return false;
	}

	//default constructor
	public Coord() {
		latitude = 0;
		longitude = 0;
	}
	
    public Coord(double lat, double lon) {
    	latitude = lat;
    	longitude = lon;
    }
    
    public Coord(int latHour, int latMin, int lonHour, int lonMin) {
    	this(latHour, latMin, 0, lonHour, lonMin, 0);
    }

    public Coord(int latHour, int latMin, int latSec, int lonHour, int lonMin, int lonSec) {
    	latitude = latHour + (latMin + (latSec/60.0))/60.0;
    	longitude = lonHour + (lonMin + (lonSec/60.0))/60.0;
    }
    
    public double getLatitude() {
    	return latitude;
    }
    
    public double getLongitude() {
    	return longitude;
    }
    
    public String toString() {
    	String xMod, yMod; //eastwest and northsouth modifiers to the coordinate
    	String output;
    	
    	if (latitude <= 0) yMod = "S";
    	else yMod = "N";
    	
    	if (longitude <= 0) xMod = "W";
    	else xMod = "E";
    	
		int hour = (int)latitude;
		int minute = (int)((latitude - hour)*60);
		int second = (int)((latitude - hour - (minute/60.0))*3600.0);
    	
    	output = Integer.toString(hour) + "*";
    	output += Integer.toString(minute) + "'";
    	output += Integer.toString(second) + '"' + yMod + ", ";
    	
    	hour = (int)longitude;
		minute = (int)((longitude - hour)*60);
		second = (int)((longitude - hour - (minute/60.0))*3600.0);
		
    	output += Integer.toString(hour) + "*";
    	output += Integer.toString(minute) + "'";
    	output += Integer.toString(second) + '"' + xMod;
    	
    	return output;
    }
}